﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI;
using AjaxControlToolkit;

namespace Ribbon.Web
{
    internal class CustomTabContainer : TabContainer   
    {
        private Action<HtmlTextWriter> RenderMenu;
        public CustomTabContainer(Action<HtmlTextWriter> renderMenu)
        {
            this.RenderMenu = renderMenu;
        }

        protected override void RenderHeader(System.Web.UI.HtmlTextWriter writer)
        {
            writer.AddAttribute(HtmlTextWriterAttribute.Id, ClientID + "_header");
            writer.RenderBeginTag(HtmlTextWriterTag.Div);

            if (RenderMenu != null && ShowMenu)
                RenderMenu(writer);

            foreach (CustomTabPanel panel in Tabs.Cast<CustomTabPanel>().Where(panel => panel.Visible))
            {
                panel.InternalRenderHeader(writer);
            }

            writer.RenderEndTag();
        }

        protected internal bool ShowMenu { set; get; }
    }

    internal class CustomTabPanel : TabPanel
    {
        protected internal void InternalRenderHeader(HtmlTextWriter writer)
        {
            this.RenderHeader(writer);
        }
    }
}
